<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/views/common/taglibs.jsp" %>
<%@ include file="/WEB-INF/views/common/head.jsp" %>
<html>
<head>
    <script src="${webRoot }static/js/jquery/jquery-1.11.3.min.js" type="text/javascript"></script>
</head>
<body onload="javascript:pay();">
<script type="text/javascript">
    function pay(){
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        }else{
            onBridgeReady();
        }
    }
    function onBridgeReady(){
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId" : "${appid}",     //公众号名称，由商户传入
                    "timeStamp": "${timeStamp}",         //时间戳，自1970年以来的秒数
                    "nonceStr" : "${nonceStr}", //随机串
                    "package" : "${packageValue}",
                    "signType" : "MD5",         //微信签名方式:
                    "paySign" : "${paySign}"    //微信签名
                },function(res){
                    if(res.err_msg == "get_brand_wcpay_request:ok"){
                        alert("微信支付成功!");
                    }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
                        alert("用户取消支付!");
                    }else{
                        alert("支付失败!");
                    }
                });
    }
</script>
</body>
</html>
